Skip to content

The pool walk's statistics no longer make a chunk of a large pool for every texture they ask about - #2085

Closed
lunks wants to merge 1 commit into
seedds:mainfrom
lunks:pr/pool-peek
Closed

lunks wants to merge 1 commit into
seedds:mainfrom
lunks:pr/pool-peek

Conversation

@lunks

@lunks lunks commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

What and why

Ocarina of Time's area load makes GPU allocated jump by 6-10 GB and it stays there. zdevi's runs in #2068 on a 16 GB M5: 3.3 GB at frame 900, 15.8 GB at frame 1200, 17-18 GB after. Our M5 Pro census (GPU allocation census) showed the same step: Metal minus the listed set went from 0.1-1.4 GB to 8 GB inside one area load and stayed.

Cause: the pool walk's log (pool walk: ... in wired pools, the first pool-table build of a scene and every 500th after) and the raw-memory log's pool age call pool_find(addr, 1) for where each texture's storage lies. For a large pool (BIG_MIN and up) pool_find makes the stride's chunk, a zero-copy buffer; length 1 means BIG_UNKNOWN past the address, so 80 MB or more, not in the residency set, overlapping its neighbours, used by no GPU work. Ocarina's pool is 2,432 MB (153 strides) and the walk touched 77 of them: 6.7 GB, which currentAllocatedSize counts in full for a no-copy buffer. The pages are shared, so resident memory does not grow by that much, but a 16 GB Mac reaches 17-18 GB allocated.

Change: pool_peek(addr) answers the same question with no side effect (the stride's entry if it has one, else -1); both statistics use it. Nothing else changes: lookups that the GPU needs still make their chunk.

Relates to #2068 (does not claim to close it: that report also has slow stretches I have not isolated).

Checked

  • Tests: make -C dm/gfx/tests GAME=0400486024DEC000 check_t_pool_chunks (149 checks, 3 new: asking where an address is makes no chunk, peek finds the chunk of a stride that has one, peek of a stride with none returns -1 and still makes none), t_cpu_storage 68, t_feedback 207, all 0 failed; docs_symptoms.py --check current.
  • Games run: Ocarina of Time 0400486024DEC000 v131072, Death Mountain repro on our stack, both runs with the same lazy pool buffers (so the whole drop below is this change): before, Metal 13.30 GB, 3,870 pool buffers made = 8.60 GB for 3.98 GB of pools, 77 of them chunk buffers outside the set (6.7 GB); after, Metal 6.21 GB at the same repro point (-7.1 GB), 0 chunk buffers outside the set, clean to frame 15,300.
  • Devices and OS: M5 Pro, macOS 27.
  • Not checked: upstream main itself with only this change (the stack has other host changes; main's eager pool buffers add about 1 GB at the same point); the other games with large pools; iOS. regress.py check was not run: the change is two statistics and a read-only lookup.
  • Measurements: see above.

Docs

  • Reference entry docs/reference/memory.md ("The pool walk's statistics made chunks of a large pool"), the game note bullet, and docs_symptoms.py run
  • No chain tool changed
  • No game files, keys or data extracted from a game in the change or the attachments

… every texture they ask about

The first pool walk of a scene (and every 500th after) asks pool_find(lo, 1) where each registered texture's storage lies, to log how much of it is in wired pools; the raw-memory
log's pool age asks the same. pool_find makes the chunk of a large pool's stride when it has none, and a length of 1 means BIG_UNKNOWN past the address: a zero-copy buffer of 80 MB or
more, not in the residency set, counted by Metal in full. In Ocarina of Time's area load (pool of 2,432 MB, 153 strides) the walk made 77 of them, 6.7 GB of currentAllocatedSize for
pages other buffers already map. pool_peek answers the same question without making anything. t_pool_chunks: 3 new checks. Reference entry and game note added.
@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation game: 0400486024DEC000 A game labels Nov 9, 2026
betogzo added a commit to betogzo/nxnative that referenced this pull request Nov 10, 2026
seedds#2030, seedds#2077, seedds#2022, seedds#2075, seedds#2085), last merged at 04811a6, and the Castle Town result on a MacBook Air M4

Castle Town on a 16 GB MacBook Air M4 at 30 fps and full resolution: GPU p50 26-27 ms a frame and 6.9 GB of GPU memory allocated with seedds#2085, against 16.2 GB and about 9 fps before it.

Tests: dm/tools/tests/test_docs.py passes.
seedds added a commit that referenced this pull request Nov 10, 2026
…rge pool for every texture they ask about: the pool walk's log (the first pool-table build of a scene and every 500th after) and the raw-memory log's pool age asked pool_find(addr, 1), which for a large pool makes the stride's chunk, a zero-copy buffer reaching BIG_UNKNOWN past the address (80 MB and more), or lengthens a shorter one to that. In Ocarina of Time's area load (pool of 2,432 MB, 153 strides) that made 77 chunks outside the residency set, 6.7 GB of currentAllocatedSize; Metal went from 13.3 to 6.2 GB at the same point on an M5 Pro. pool_peek answers with the stride's chunk if it has one, else -1; it shares pool_find's search of the other entries (pool_held). t_pool_chunks: 3 new checks (PR #2085, issue #2068)

Co-authored-by: Pedro Nascimento <91118+lunks@users.noreply.github.com>
@seedds

seedds commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Landed as 6f50de0, with you as co-author. Your diagnosis, pool_peek, the two call sites and the three t_pool_chunks checks are unchanged. One restructure: pool_find and pool_peek now share the search of the other entries (pool_held) instead of each having its own copy, so they differ only for a large pool. The reference entry also notes a second effect: the length-1 lookup lengthened a stride's existing shorter chunk to BIG_UNKNOWN as well, and the GPU's next lookup in that stride then made the longer chunk resident beside the old one. Checked: host build, t_pool_chunks 149/0, t_cpu_storage 68/0, feedback 281/0, docs tests. No game run here; the Ocarina numbers are yours. #2068 stays open for its slow stretches. Thanks!

@seedds seedds closed this Nov 10, 2026
FeReuss pushed a commit to FeReuss/nxnative-oot that referenced this pull request Nov 10, 2026
… longer make a chunk of a large pool for every texture they ask about

kept both sides of dm/games/0400486024DEC000/README.md

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
FeReuss pushed a commit to FeReuss/nxnative-oot that referenced this pull request Nov 10, 2026
…ed commit, which the next merge brings

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
FeReuss pushed a commit to FeReuss/nxnative-oot that referenced this pull request Nov 10, 2026
Conflicts resolved by hand:
- seedds#2085, seedds#2078 and seedds#2065 came back from upstream as reworked commits (6f50de0, 12a44e0, 5e1c1ae): our three merges were reverted first, so the merge brings upstream's version instead of two copies.
- GPU copies into a texture (copy_b2t, mirror_rb_land, nvn_obj.h): upstream's seedds#1310 rework (mspan_t, pkg_copy_absorb, for the readback case) and our seedds#2077 (mirror_rb_own, gsb_mark, for a texture the GPU owns) cover different cases and both stay: own = !rb is taken before the synchronous mirror, so the two paths exclude each other. mirror_rb_own passes no span.
- loader.c: upstream's render-scale parse with the stub's largest scale (Hades II) and our graphics-scale tier block. t_readback.m: upstream's additive tests added to ours. pso_offline.py: its header comment. Docs and tables keep both sides; DM_RENDER_SCALE rows, render_base and the settings table take upstream's Hades II range plus our text.
- dmsh_chain.h regenerated; .github/workflows/tests.yml follows upstream (a test list).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
iDams pushed a commit to iDams/nxnative that referenced this pull request Nov 10, 2026
…rge pool for every texture they ask about: the pool walk's log (the first pool-table build of a scene and every 500th after) and the raw-memory log's pool age asked pool_find(addr, 1), which for a large pool makes the stride's chunk, a zero-copy buffer reaching BIG_UNKNOWN past the address (80 MB and more), or lengthens a shorter one to that. In Ocarina of Time's area load (pool of 2,432 MB, 153 strides) that made 77 chunks outside the residency set, 6.7 GB of currentAllocatedSize; Metal went from 13.3 to 6.2 GB at the same point on an M5 Pro. pool_peek answers with the stride's chunk if it has one, else -1; it shares pool_find's search of the other entries (pool_held). t_pool_chunks: 3 new checks (PR seedds#2085, issue seedds#2068)

Co-authored-by: Pedro Nascimento <91118+lunks@users.noreply.github.com>
betogzo added a commit to betogzo/nxnative that referenced this pull request Nov 10, 2026
seedds#2085: upstream merged them (6c3aeb3, 6d9edb0, 6c67644, 6f50de0), and the merge that follows takes upstream's versions

Reverts 0218338, faa7afe, cfce7d8, f92d3f3 and a74098c.
betogzo added a commit to betogzo/nxnative that referenced this pull request Nov 10, 2026
 and seedds#2085 in upstream's versions, the host at -O2, Ocarina of Time's camera-turn hitch in Hyrule Field (230 → 39 ms), 41 more task / mesh pipelines and 4,959 render / compute pipelines in its prewarm list, GPU writes into uploaded textures kept on the GPU, compact NVN recordings; chain 8f2d8a09c3f9

PR seedds#2030 (blend_zero) stays the fork's own: upstream moved the shader build's MSL rewrites into dmsh_rewrite.py (80fc2ec), so blend_zero and BLEND_ZERO move there, dmsh_build.py finish calls dmsh_rewrite.blend_zero, and test_dmsh_blend_zero.py imports it. dmsh_chain.h regenerated (8f2d8a09c3f9).

Tests: test_dmsh_*.py 26/26 OK (test_dmsh_pairs with DM_GAME=0400486024DEC000); t_pool_chunks 151/0, t_cpu_storage 135/0, t_readback 218/0, t_pool_seen_replace 44/0, t_pool_standin 31/0, t_pool_notes 81/0, t_mesh_first_use 53/0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0400486024DEC000 A game nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants